//
//  DWDStatusTopView.swift
//  dwdWb
//
//  Created by Dengdwd on 15/10/12.
//  Copyright © 2015年 dwd. All rights reserved.
//

import UIKit
import SDWebImage
class DWDStatusTopView: UIView {
    
    var statusModel:DWDStatusModel? {
        didSet {
            nameLabel.text = statusModel?.status.user?.name
            iconView.sd_setImageWithURL(statusModel?.userIconUrl)
            memberView.image = statusModel?.userMemberImage
            vipView.image = statusModel?.userVipImage
            sourceLabel.text = statusModel?.sourceText
            timeLabel.text = statusModel?.creatDateStr
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setUpUI() {
    addSubview(iconView)
    addSubview(nameLabel)
    addSubview(memberView)
    addSubview(timeLabel)
    addSubview(sourceLabel)
    addSubview(vipView)
        
    let point = CGPoint(x:DWDStatusMargin,y:0)
    iconView.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSize(width: DWDStatusHeight, height: DWDStatusHeight), offset: CGPoint(x:DWDStatusMargin,y: DWDStatusMargin))
    nameLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: point)
    memberView.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: nameLabel, size: nil, offset: point)
    timeLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: point)
    sourceLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: timeLabel, size: nil, offset: point)
    vipView.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 8, y: 8))
    }
    private lazy var iconView:UIImageView = UIImageView(image: UIImage(named:"avatar_default_big"))
    private lazy var nameLabel:UILabel = UILabel(title: "姓名", color: UIColor.darkGrayColor(), fontSize: 14)
    private lazy var memberView:UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level1"))
    private lazy var timeLabel:UILabel = UILabel(title: "刚刚", color: UIColor.orangeColor(), fontSize: 10)
    private lazy var sourceLabel:UILabel = UILabel(title: "来自 新浪微博", color: UIColor.darkGrayColor(), fontSize: 10)
    private lazy var vipView:UIImageView = UIImageView(image: UIImage(named: "avatar_grassroot"))
}
